﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using AnaxibiaStudios.Smug;

namespace SmugTest
{
  [TestClass]
  public class NonStandardMethodAccessTest
  {
    delegate int TryGetAltitudeSignature(out int altitude);

    [TestMethod]
    public void CustomDelegateTest()
    {
      var airplane = Create.Proxy<Airplane>();
#if DETOUR_ENABLED
      Prepare.Method<TryGetAltitudeSignature>(airplane.TryGetAltitude).ReplaceWith(TryGetDetour);

      int alt;
      airplane.TryGetAltitude(out alt);

      Assert.AreEqual(4, alt);
#endif
    }

    int TryGetDetour(out int alt)
    {
      alt = 4;
      return 2;
    }
  }
}
